#pragma once

#include <vector>
#include "Fatworm.h"
#include "Island.h"
#include "ShipGroup.h"

class Commander
{
public:
	vector<Fatworm> enemies;
	vector<Fatworm> ours;
	vector<Island> islands;
private:
	static Commander *me;
	int team;
	float **dist2Island, dist2Enemies[5][5];
	vector<ShipGroup> groups;
	float lastActionTime;
public:
	~Commander(void);
	static Commander& getInstance(void);

	void beforeUpdate( void );
	void afterUpdate( void );
	void updateOurs( ShipInfo& ship );
	void updateEnemies( ShipInfo& ship );
	void updateIslands( vector<ResourceInfo>& islands );
	void setTeam( int x );

	void makeOrder(void);
	void spreadShipInfo( void );
	void explore(vector<int> idxes);
	void regularCheck( void );

	void act( OSInterface* const system );

private:
	Commander(void);
	template<typename T1, typename T2>
	void update(T1& ship, vector<T2>& list);
	void merge(int shipIdx);
	void groupShips( void );
};
